package com.pingpang.util;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPoolUtil {

	public static ThreadPoolExecutor getThreadPool(final int coreSize,final int maxSize) {
		ThreadPoolExecutor threadPools=new ThreadPoolExecutor(
				coreSize,
				maxSize,
				60,
				TimeUnit.SECONDS,
				new LinkedBlockingQueue<Runnable>(100),
				new RejectedExecutionHandler() {
                    @Override
                    public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
                        throw new RuntimeException("线程池已满");
                    }
                });
		return threadPools;
	}
}
